<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            height: 600px;

            outline: 2px solid red;
        }

        body {
            margin: 0;
            padding: 0;
            height: 2000px;
        }

        .smaller {
            transform: scale(0.6);
        }

        .box {
            text-align: center;
            margin-top: 50px;

        }

        img {
            transition: 0.3s;
        }

        .myanimate {
            animation-play-state: paused;
        }

        .run {
            animation-play-state: running !important;
        }
    </style>
    <link rel="stylesheet" href="./css/animation.css">
</head>

<body>
    <div class="box"></div>
    <div class="box">
        <img class=" myanimate animated  fadeInRight " src="./img/a5.jpg" alt="">
    </div>
    <div class="box">
        <img class=" myanimate animated  jello " src="./img/a9.jpg" alt="">
    </div>

    <script>
        window.console.log('a')
        let animateionEles = document.querySelectorAll('.myanimate')
        let animateDistance = 100
        window.onscroll = function (e) {
            animateionEles.forEach(function (el) {
                if ((innerHeight - (el.offsetTop - scrollY) - el.offsetHeight) >= animateDistance) {
                    el.classList.add('run')
                }
            })
        }
    </script>
</body>

</html>